﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;

/// <summary>
/// DAO manager manages all data processes and serves as bridge to connection manager
/// </summary>
public class DAOManager
{
    public DAOManager() { }

    public ArrayList getUserCompanies(int _userid)
    {
        ArrayList ret = new ArrayList();

        //string sqlString = "";

        //sqlString += " SELECT";
        //sqlString += " CON.ContactID, USR.UserID, USR.FirstName, USR.Surname, COM.CompanyID, COM.CompanyName";
        //sqlString += " FROM Contacts CON";
        //sqlString += "       inner join [Companies] COM on CON.CompanyID = COM.CompanyID";
        //sqlString += "       inner join [Users2] USR on USR.UserID = CON.UserID";
        //sqlString += " WHERE USR.UserID = @userid";
        //sqlString += " ORDER by CON.ContactID asc";

        //DataTransformerUtility utility = new DataTransformerUtility();
        //ConnectionMaster connection = new ConnectionMaster();

        //ArrayList parameterlist = new ArrayList();
        //parameterlist.Add(new SqlParameter("@userid", _userid));

        //DataTable dt = connection.retrieveDataTable(sqlString, parameterlist);

        //for (int i = 0; i < dt.Rows.Count; i++)
        //{
        //    UserCompany userComp = new UserCompany();
        //    DataRow dr = dt.Rows[i];

        //    userComp.ContactID = Int32.Parse(utility.extractStringValue(dr["ContactID"], DataTransformerUtility.DataType.PRIMARYKEY));
        //    userComp.UserID = Int32.Parse(utility.extractStringValue(dr["UserID"], DataTransformerUtility.DataType.PRIMARYKEY));
        //    userComp.FirstName = utility.extractStringValue(dr["FirstName"], DataTransformerUtility.DataType.STRING);
        //    userComp.Surname = utility.extractStringValue(dr["Surname"], DataTransformerUtility.DataType.STRING);
        //    userComp.CompanyID = Int32.Parse(utility.extractStringValue(dr["CompanyID"], DataTransformerUtility.DataType.PRIMARYKEY));
        //    userComp.CompanyName = utility.extractStringValue(dr["CompanyName"], DataTransformerUtility.DataType.STRING);

        //    ret.Add(userComp);
        //}
        return ret;

    }   
}